﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Data.SQLite;
using System.Data;
namespace kwt.data
{
    public class DataAccess
    {
        private static readonly string dbPath = Environment.CurrentDirectory + "\\temp.dat";

        public static string ConnString
        {
            get
            {
                return string.Format("Data Source={0};Password=828488", dbPath);
            }
        }

        public static IDbConnection Connection
        {
            get
            {
                return new SQLiteConnection(ConnString);
            }
        }

        public static bool CheckDb
        {
            get
            {
                try
                {
                    Connection.Open();
                    Connection.Close();
                }
                catch(SQLiteException)
                {
                    SQLiteConnection.CreateFile(dbPath);
                    Connection.Open();
                
                }

                return true;
            }
        }
    }
}
